<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/pintuer.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/admin.css">
<script src="${pageContext.request.contextPath}/static/js/jquery.js"></script>
<script src="${pageContext.request.contextPath}/static/js/pintuer.js"></script>

</head>
<body>
<form method="post" action="" id="listform">
  <div class="panel admin-panel" id="menu">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
      <template v-for="(item, index) in menus">
      <template v-if="add == item.menuName" >
        <li> <a :href="baseUrl + item.menuUrl + '&pageNum=1 &tgId=' + item.menuPid" class="button border-main icon-plus-square-o">{{item.menuName}}</a> </li>
       </template>
       </template>
        <li>
          <input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a></li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        
        <th>工号</th>
        <th>密码</th>
        <th>姓名</th>
        <th width="310">操作</th>
      </tr>
      <volist name="list" id="vo">
      	<c:forEach items="${requestScope.pageBean.list }" var="user">
        <tr>
         
        	<td>${user.userId }</td>
			<td>${user.password }</td>
			<td>${user.username}</td>
        
          <td>
          <template v-for="(item, index) in menus">
          <div class="button-group">
          <template v-if="edit == item.menuName" >
          <a :href="baseUrl + item.menuUrl + '&userid=${user.userId }&tgId=' + item.menuPid" class="button border-main"><span class="icon-edit"></span>{{item.menuName}}</a>
         
          </template>
          <template v-if="del == item.menuName" >
          
         <%-- /sys/illtype.do?method=deleteIllTypePage <a :href="javascript:;" class="button border-red" onclick="return del('baseUrl + {{item.menuUrl}}','${area.id}','{{item.menuPid}}'"><span class="icon-trash-o"></span>{{item.menuName}}</a> --%>
          <a class="button border-red" href="javascript:;" onclick="return del('${pageContext.request.contextPath}/sys/user.do?method=deleteUser','${user.userId }')"><span class="icon-trash-o"></span> {{item.menuName}}</a>
          </template>
          </div>
          </template>
          </td>
        </tr>
   		</c:forEach>
   	  <tr>
        <td colspan="8">
       
         <div class="pagelist">

		 当前 ${requestScope.pageBean.pageNum} / 
					${requestScope.pageBean.totalPage }页，共 ${requestScope.pageBean.totalRecord} 条
		
			<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=1&tgId=${tgId}">首页</a>
			
						<%--如果当前页为第一页时，就没有上一页这个超链接显示 --%>
				<c:if test="${requestScope.pageBean.pageNum ==1}">
					<c:forEach begin="${requestScope.pageBean.start}"
						end="${requestScope.pageBean.end}" step="1" var="i">
						<c:if test="${requestScope.pageBean.pageNum == i}">
								<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${i}&tgId=${tgId}">${i}</a>
						</c:if>
						<c:if test="${requestScope.pageBean.pageNum != i}">
							<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${i}&tgId=${tgId}">${i}</a>
						</c:if>
					</c:forEach>
					<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${requestScope.pageBean.pageNum+1}&tgId=${tgId}">下一页</a>
				</c:if>
		
			
						<%--如果当前页不是第一页也不是最后一页，则有上一页和下一页这个超链接显示 --%>
					<c:if
						test="${requestScope.pageBean.pageNum > 1 && requestScope.pageBean.pageNum < requestScope.pageBean.totalPage}">
						<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${requestScope.pageBean.pageNum-1}&tgId=${tgId}">上一页</a>
						<c:forEach begin="${requestScope.pageBean.start}"
							end="${requestScope.pageBean.end}" step="1" var="i">
							<c:if test="${requestScope.pageBean.pageNum == i}"><a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${i}&tgId=${tgId}">${i}</a></c:if>
							<c:if test="${requestScope.pageBean.pageNum != i}">
								<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${i}&tgId=${tgId}">${i}</a>
							</c:if>
						</c:forEach>
						<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${requestScope.pageBean.pageNum+1}&tgId=${tgId}">下一页</a>
					</c:if>
			
			
	
	
			
					<%-- 如果当前页是最后一页，则只有上一页这个超链接显示，下一页没有 --%>
					<c:if
						test="${requestScope.pageBean.pageNum == requestScope.pageBean.totalPage}">
						<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${requestScope.pageBean.pageNum-1}&tgId=${tgId}">上一页</a>
						<c:forEach begin="${requestScope.pageBean.start}"
							end="${requestScope.pageBean.end}" step="1" var="i">
							<c:if test="${requestScope.pageBean.pageNum == i}"><span class="current">${i}</span></c:if>
							<c:if test="${requestScope.pageBean.pageNum != i}">
								<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${i}&tgId=${tgId}">${i}</a>
							</c:if>
						</c:forEach>
					</c:if>
			
			<a href="${pageContext.request.contextPath}/sys/user.do?method=findUserByPage&pageNum=${requestScope.pageBean.totalPage}&tgId=${tgId}">尾页</a>
			
			
		
	     </div>
        </td>
      </tr>
    </table>
</div>
</form>




	<script src="${pageContext.request.contextPath}/static/js/vue.min.js"></script>

	<!-- vue 遍历菜单 -->
	<script type="text/javascript">
   
   
    	var _vm = new Vue({
    		el : "#menu",
    		data : {
    		baseUrl : '${pageContext.request.contextPath}',
    		menus : ${resultMenus},
    		add:"添加用户",
			del:"删除用户",
			edit:"修改用户"
    		}
    	});
        
    	//单个删除
    	function del(uri,id){
    		
    		if(confirm("您确定要删除吗?")){
    			$.ajax({
    				type:'POST',
    				url: uri, 
    				dataType:'json',
    				data:{
    					userid : id
    					
    				},
    				async: false,
    				success:function(msg){
    						var flag="true";
    	                //根据后台返回前台的msg给提示信息加HTML
    	                if(flag !=msg){
    	                	window.location.reload();
    	                	alert("删除成功！");
    	                	
    	                	}
    	                else{
    	                	window.location.reload();
    	                	alert("删除失败已经绑定了用户");
    	                }
    				},
    				error:function(data , c){
    					alert("服务器异常");
    				}
    			});	
    		}

    	}
    </script>

</body>
</html>